﻿//////////////////////////////////////////////////////////////////
//
// Charles\SrtmTileStore.cs
//
// Copyright (c) 2012 Dan Pike.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation files
// (the "Software"), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Utilities;

namespace Charles
{
   ////////////////////////////////////////////////////////////////////////
   /// <summary>
   /// 
   /// </summary>
   public class SrtmTileStore
   {
      private static Logger logger_;

      /// <summary>
      /// How many arc-seconds per height point in the SRTM file (either 1 or 3)
      /// </summary>
      public const int SRTM_ARCSECONDS_PER_POINT = 1;

      /// <summary>
      /// The number of height points per row/column in the file (1201 for SRTM3, 3601 for SRTM1)
      /// </summary>
      public const int SRTM_POINTS_PER_ROW = (3600 / SRTM_ARCSECONDS_PER_POINT) + 1;
      public const int SRTM_POINTS_PER_COLUMN = SRTM_POINTS_PER_ROW;

      /// <summary>
      /// The number of height points in each SrtmTile
      /// </summary>
      public const int SRTM_SIZE_LONGITUDE = 300;
      public const int SRTM_SIZE_LATITUDE = 300;

      /// <summary>
      /// The number of arc seconds covered by a tile
      /// </summary>
      public const int SRTM_ARCSECONDS_PER_TILE_LONGITUDE = SRTM_SIZE_LONGITUDE / SRTM_ARCSECONDS_PER_POINT;
      public const int SRTM_ARCSECONDS_PER_TILE_LATITUDE = SRTM_SIZE_LATITUDE / SRTM_ARCSECONDS_PER_POINT;

      /// <summary>
      /// Height value used when there is no data available for that location
      /// </summary>
      public const short SRTM_VOID_DATA = -32768;

      /// <summary>
      /// Height value used when we haven't processed the segment, yet
      /// </summary>
      public const short SRTM_NO_HEIGHT = -32767;

      /// <summary>
      /// Height value used when it lies outside the expected range (signal noise)
      /// </summary>
      public const short SRTM_INVALID = -32766;

      /// <summary>
      /// The bottom and top of the "world" for scaling in the Z-direction.
      /// Mariana trench is 10,971m deep but we only count land that is below
      /// sea-level, as the SRTM data doesn't show land under water. For that,
      /// the Dead sea is at -424m. Everest is 8850m above sea-level.
      /// </summary>
      public const int SRTM_MIN_HEIGHT = -500;
      public const int SRTM_MAX_HEIGHT = 9000;

      ////////////////////////////////////////////////////////////////////////
      /// <summary>
      /// 
      /// </summary>
      static SrtmTileStore()
      {
         logger_ = Program.Logger;
      }

      ////////////////////////////////////////////////////////////////////////
      /// <summary>
      /// 
      /// </summary>
      public SrtmTileStore()
      {
      }
   }
}
